<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="" method="post" id="editForm">
    <input type="text" hidden class=""  readonly  name="id" placeholder="id" value="{$data.id}">
    <br>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-username" disabled id="title" name="title" placeholder="用户名" value="{$data.name}">
        </div>
    </div>
    <br>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" class="layui-input field-username" id="password" name="password" placeholder="请输入新密码">
        </div>
    </div>
    <br>
    <div class="layui-form-item">
        <label class="layui-form-label">职务:</label>
        <div class="layui-input-inline">
            <select name="city" value="">
                {foreach $job as $value}
                {if $value.name !== "超级管理员"}
                <option value="{$value.id}" {if $value.id == $data.role_id} selected  {/if}>{$value.name}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="padding-left: 110px">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit  lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">确认修改</button>
    </div>

</form>
<script>
    layui.use(['form'], function() {
        var $ = layui.jquery,
            form = layui.form;

        form.on("submit(formSubmit)",function(data){
            layer.msg('密码修改中...', {
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function(){
                $.ajax({
                    url:"{:url('edit')}",
                    type:"POST",
                    data:data.field,
                    dataType:"JSON",
                    success (res) {
                        layer.msg(res.msg);
                        setTimeout(function(){
                            layer.closeAll();
                            if (res.code === 1){
                                var index = parent.layer.getFrameIndex(window.name);//关闭当前页面
                                window.parent.location.reload();
                                parent.layer.close(index);
                            }
                        },1000);
                    }
                })
            });
            return false;
        })

    });

</script>

</body>
</html>